package org.springblade.tms.global.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springblade.common.enums.Enumerator;
import org.springblade.tms.global.anno.SelectEnum;

/**
 * @projectName: BladeX
 * @package: org.springblade.tms.global.enums
 * @className: OrderTypeEnum
 * @author: yr
 * @description: 父单据类型
 * @date: 2022/3/29 16:29
 */
@AllArgsConstructor
@Getter
@SelectEnum(value = "OrderType", desc = "异常记录单据类型")
public enum OrderTypeEnum implements Enumerator {
	SINGLE_TRANSPORT("transport", "运输单"),
	DEMAND_LIST("demand", "需求单");

	private final String value;
	private final String description;

	@Override
	public String value() {
		return value;
	}

	@Override
	public String description() {
		return description;
	}

	//根据desc获取value
	public static String getDescriptionByValue(String value) {
		for (OrderTypeEnum orderTypeEnum : OrderTypeEnum.values()) {
			if (orderTypeEnum.getValue().equals(value)) {
				return orderTypeEnum.getDescription();
			}
		}
		return null;
	}
	//根据value获取desc
	public static String getValueByDescription(String description) {
		for (OrderTypeEnum orderTypeEnum : OrderTypeEnum.values()) {
			if (orderTypeEnum.getDescription().equals(description)) {
				return orderTypeEnum.value();
			}
		}
		return null;
	}
}
